--- Example code for Issue 126
module tests.comp.Issue126 where

import frege.Prelude hiding(Byte)
-- import Data.List

data Byte = pure native "byte" where
    pure native byte "(byte)" :: Int -> Byte
    --- this gives the 'Int' corresponding to the *signed* interpretation of the 'Byte'
    pure native signed "(int)"  :: Byte -> Int
    --- this gives the 'Int' corresponding to the *unsigned* interpretation of the 'Byte'
    unsigned b = signed b Int..&. 0xFF
    hashCode  = Byte.unsigned 

instance Eq Byte where
    -- hashCode  = Byte.unsigned
    pure native == :: Byte -> Byte -> Bool
    pure native != :: Byte -> Byte -> Bool

main = print (hashCode (Byte.byte 142)) >> println " (should be 142)"